I'm trying to create a folder that will contain all images of an image album. Unfortunately, when I try to use File::makeDirectory I get the "mkdir(): No such file or directory" error. Now, I am either using it incorrectly or there's something wrong with my path. My goal is to create a folder called $albumName in my albums folder. Also considering I'm using php artisan storage:link, should my path be:
public/albums/'.$albumName
or
public/storage/albums/'.$albumName
My code so far.
public function uploadAlbum(Request $request){
$albumName = $request['albumName'];
$albumPath = File::makeDirectory('public/albums/'.$albumName);
return redirect()->route('home');
}
the error
C:\MAMP\htdocs\LaravelProject\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php
return $directories;
}
/**
* Create a directory.
*
* @param string $path
* @param int $mode
* @param bool $recursive
* @param bool $force
* @return bool
*/
public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
{
if ($force) {
return @mkdir($path, $mode, $recursive);
}
return mkdir($path, $mode, $recursive);
}
/**
* Move a directory.
*
* @param string $from
* @param string $to
* @param bool $overwrite
* @return bool
*/
public function moveDirectory($from, $to, $overwrite = false)
{
if ($overwrite && $this->isDirectory($to)) {
if (! $this->deleteDirectory($to)) {
return false;
}
}
return @rename($from, $to) === true;
}
Arguments
"mkdir(): No such file or directory"
Copyright Notice:Content Author:「Onyx」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48912160/after-using-filemakedirectory-in-laravel-i-get-mkdir-no-such-file-or-dire